﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Utility.Json
{
    public class JsonRetData
    {
        /// <summary>
        /// JsonRetData实例化
        /// </summary>
        public JsonRetData()
        { }
        /// <summary>
        /// JsonRetData实例化
        /// </summary>
        /// <param name="state">ajax 执行的结果true: 成功false: 失败</param>
        /// <param name="message">出错信息、提示信息</param>
        /// <param name="retcode">开发人员自定义的代码</param>
        /// <param name="retdata">正常返回的结果</param>
        public JsonRetData(string state, string message, string retcode, string retdata)
        {
            this.State = state;
            this.Message = message;
            this.RetCode = retcode;
            this.RetData = retdata;
        }
        /// <summary>
        /// ajax 执行的结果
        /// true: 成功
        /// false: 失败
        /// </summary>
        public string State { get; set; }

        /// <summary>
        /// 出错信息、提示信息
        /// </summary>
        public string Message { get; set; }

        /// <summary>
        /// 开发人员自定义的代码
        /// </summary>
        public string RetCode { get; set; }

        /// <summary>
        /// 正常返回的结果
        /// </summary>
        public string RetData { get; set; }

        /// <summary>
        /// 组合json字符串
        /// </summary>
        /// <returns></returns>
        public string AssemblyJson()
        {
            return "{\"State\":\"" + State + "\", \"Message\":\"" + Message.ToReplace() + "\", \"RetCode\":\"" + RetCode + "\",\"RetData\":\"" + RetData + "\" }";
        }
    }
}
